11. Hover Controller
Hover Controller
As discussed earlier, a quadrotor has four independent degrees of freedom:
- Roll (rotation about X-axis) - causing a simultaneous translation in the Y
- Pitch (rotation about Y-axis) - causing a simultaneous translation in the X
- Yaw (rotation about Z-axis)
- Motion along Z-axis
A hover controller, in essence controls only one independent degree of freedom, the motion along the Z-axis.
A simple PID based hover controller calculates the difference between a given target height and the current altitude of the quadrotor to obtain the error signal, and then tries to minimize this error by adjusting (controlling) the total thrust along the z-axis of the quadrotor.
An example hover_controller_node
is provided in the quad_controller
package that utilizes the PID controller class that you have implemented.
To test this Hover Controller, you need to bring up the quadrotor simulator and launch the hover_controller_node
.
Since the quadrotor simulator uses ros topics and services for interaction, you must bring up ROS Master before launching the simulator.
To do so, open a fresh terminal and fire up roscore
$ roscore
Now you are ready to launch the quad simulator on your host platform.
Launching the Simulator
The details surrounding this process will be different for each host platform (Win/Mac/Linux), please refer to the "Using the Simulator" section of the lab README file.
If presented with the option, select the desired screen solution and graphics quality that your computer system can comfortably handle and then click “OK”.
If everything went well, your window should look something like this:
Notice the “Connected to ROS” message being displayed at the bottom-left corner of the screen.
If the message says “Connecting to ROS” for more than a few seconds, then you might want to check your firewall settings on your host VM, or try restarting the simulator.
In addition, verify that you can see poses being published by the simulator on the /quad_rotor/pose
topic:
$ rostopic echo /quad_rotor/pose
If you see messages being published, you're good to go. If you don't see messages being published, then again you might want to check your firewall settings on the host VM, or try restarting the simulator.
Once the simulator is properly connected to ROS, launch the hover_controller_node
$ roslaunch quad_controller hover_controller.launch
If the script is running correctly your view of the quadcopter should look like below. If it does not, quit everything and try the steps again.
You may observe that the quadrotor is essentially sitting on the ground, even though the hover_controller_node
is running.
This is because the default target height for the controller is set to zero. In order to command it to move to a new target height at runtime, we will utilize a powerful ROS utility called dynamic_reconfigure
.
Let’s have a quick look at dynamic_reconfigure
and make progress with the Hover Controller.